<style>
    .view-all{
        cursor: pointer;
        color: #01AAED;
    }
</style>
<div class="layui-layout rating-amount-wrapper" style="padding:0 20px;">
    <div id="search-wrapper">
        <div class="layui-form">
            <div class="layui-row">
                <div class="layui-inline">
                    <input class="layui-input name" name="name"  placeholder="请输入书名">
                </div>
                <div class="layui-inline">
                    <button class="layui-btn search" data-type="reload">搜索</button>
                </div>
            </div>
        </div>
    </div>
    <table class="layui-hide" id="table_list" lay-filter="table_filter">
    </table>
</div>
<script>
    layui.use(['table','form'], function(){
        var table = layui.table;
        var $ = layui.$;
        //方法级渲染
        table.render({
            elem: '#table_list'
            ,url: '/ratingamount/table'
            ,where: {
                name:$(".name").val()
            }
            ,cols: [[
                {field:'BookId', title: '小说Id', align:'center'},
                {field:'BookName', title: '小说名称', align:'center'},
                {field:'ChannelType', title: '频道类型', align:'center',templet:function (d) {
                        if(d.ChannelType == 1){
                            return "男频"
                        }else{
                            return "女频"
                        }
                    }},
                {field:'Cat', title: '类型', align:'center'},
                {field:'StatusText', title: '状态', align:'center'},
                {field:'Cnt', title: '评论数量', align:'center'},
                {field:'', title: '操作', align:'center',templet:function (d) {
                        return `<a href="/bookrating/list?name=` + d.BookName + `" class="view-all">查看全部</a>`
                    }}
            ]]
            ,id: 'listReload'
            ,page: {
                curr: location.hash.replace('#!fenye=', '') //获取起始页
                ,hash: 'fenye' //自定义hash值
            }
            ,height: "full-200"
        });

        var active = {
            reload: function(){
                table.reload('listReload', {
                    where: {
                        name:$(".name").val()
                    },
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            }
        };

        $('#search-wrapper .search').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

</script>